package com.sukaiyi.giteeideaplugin.utils;

import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUtil;

import java.util.Date;

public class HumanizedDateUtils {

    private HumanizedDateUtils() {

    }

    public static String humanize(Date time) {
        Date now = new Date();
        if (now.getTime() - time.getTime() <= 1000 * 60 * 60 * 24 * 2) {
            return DateUtil.formatBetween(time, now, BetweenFormater.Level.MINUTE) + "前";
        } else {
            return DateUtil.format(time, "yyyy-MM-dd HH:mm:ss");
        }
    }

}
